package com.hackvan2012.controllers;

import java.io.IOException;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hackvan2012.datastore.AppDatastore;
import com.hackvan2012.datastore.dao.FoodEntryObject;
import com.hackvan2012.datastore.dao.PostObject;

public class ViewEntryController extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
			throws ServletException, IOException{
		AppDatastore ds = new AppDatastore();
		String entryId = req.getParameter("entryId");
		FoodEntryObject fe = ds.getFoodEntry(entryId);
		List<PostObject> feComments = ds.getPosts(entryId);
	    
	    req.getSession().setAttribute("foodEntry", fe);
	    req.getSession().setAttribute("comments", feComments);
	    
	    req.getRequestDispatcher("/jsp/viewentry.jsp").forward(req, resp);
	    resp.getWriter().write("view entry success");
	}
	
	

}
